from typing import Optional

from sqlalchemy import BIGINT
from sqlmodel import Field

from src.base.beans import PageParam
from src.domain.base_model import TenantModel
from src.base.beans import Bigint


class SysDictBase(TenantModel):
    dict_id: Optional[Bigint] = Field(default=None, primary_key=True, description="字典序号", sa_type=BIGINT,
                                      sa_column_kwargs={"comment": "字典序号"})
    dict_type: Optional[str] = Field(default=None, description="字典类型", sa_column_kwargs={"comment": "字典类型"})
    dict_label: Optional[str] = Field(default=None, description="字典标签", sa_column_kwargs={"comment": "字典标签"})
    dict_name: Optional[str] = Field(default=None, description="字典名称", sa_column_kwargs={"comment": "字典名称"})
    dict_value: Optional[str] = Field(default=None, description="字典值", sa_column_kwargs={"comment": "字典值"})


class SysDict(SysDictBase, table=True):
    __tablename__ = "sys_dict"
    __table_args__ = {'extend_existing': True, 'comment': '字典表'}


class SysDictReq(SysDictBase, PageParam):
    create_time_range: Optional[list[str]] = Field(default=None, description="创建时间范围")
    update_time_range: Optional[list[str]] = Field(default=None, description="更新时间范围")


class SysDictResp(SysDictBase):
    pass
